
import java.util.ArrayList;

import javax.swing.JOptionPane;

import data.RTEData;
import parser.RTEXmlParser;
import tree.TreeEditDistance;
import machineLearning.Classification;
import machineLearning.ClassificationCrossValidation;
import matching.*;


public class MainRTE {

	public static void main(String[] args) {
		RTEXmlParser.readData();
		RTEXmlParser.readPreprocessedData();

		Matcher wordMatch = new WordMatch("1-a WordMatch", 0.20); 
		//0.8 without IDF = 52% ish
		//0.2 with IDF = 0.605
		wordMatch.match();
		
		Matcher lemmaMatch = new LemmaMatch("1-b lemma match", 0.40); 
		//0.6 without IDF = 0.5525
		//0.4 with IDF = 0.60875
		lemmaMatch.match();
		Matcher bleuMatch = new BLEUMatch("1-c BleuMatch", 0.7); 
		//0.3 without IDF = 0.58625 
		//0.7 with IDF = 0.60625
		bleuMatch.match();
		
//		2-A
//		TreeEditDistance ted = new TreeEditDistance("2-a Tree edit distance", 0.60f);
//		ted.setUseIDF(false);
//		ted.setUseTestTrees(false);
//		ted.setDelCost(1);
//		ted.match();
		
		//2-B
		TreeEditDistance ted2 = new TreeEditDistance("2-b Tree edit distance", 0.60);
		ted2.setUseIDF(false);
		ted2.setUseTestTrees(false);
		ted2.setDelCost(0);
		ted2.match();
//		
//		//2-C WITH INS = IDF and DEL = 0
//		TreeEditDistance ted3 = new TreeEditDistance("2-c Tree edit distance", 0.0055);
//		ted3.setUseIDF(true);
//		ted3.setUseTestTrees(false);
//		ted3.setDelCost(0);
//		ted3.match();
		
		Classification classification = new Classification("3-b Machine learning", 0);
		classification.match();
		
		ClassificationCrossValidation crossValidation = new ClassificationCrossValidation();
		crossValidation.classify();

		BestSystem system = new BestSystem("4-a Best System", 0.40);
		system.match();
//		analyseErrors(wordMatch.errors, lemmaMatch.errors, bleuMatch.errors, ted2.errors, classification.errors, awesome.errors);
	}

	private static void analyseErrors(ArrayList<Integer> errors,
			ArrayList<Integer> errors2, ArrayList<Integer> errors3,
			ArrayList<Integer> errors4, ArrayList<Integer> errors5, ArrayList<Integer> errors6) {
		
		ArrayList<Integer> intersection = intersection(errors, errors2);
		intersection = intersection(intersection, errors3);
		intersection = intersection(intersection, errors4);
		intersection = intersection(intersection, errors5);
		intersection = intersection(intersection, errors6);

		for (Integer integer : intersection) {
			System.out.println(integer);
		}
	}
	
	private static ArrayList<Integer> intersection(ArrayList<Integer> list1, ArrayList<Integer> list2) {
		ArrayList<Integer> list = new ArrayList<Integer>();
		for(int val : list1) {
			if(list2.contains(val))
				list.add(val);
		}
		return list;
	}
}